<?php
if (isset($_POST['shop_name']) AND isset($_POST['shop_tel']) 
		AND isset($_POST['shop_city']) AND isset($_POST['shop_addr'])
			AND isset($_POST['shop_cp']))
{
	if ($_POST['shop_name'] AND $_POST['shop_tel'] 
			AND $_POST['shop_city'] AND $_POST['shop_addr']
				AND $_POST['shop_cp'])
		{
		if (is_numeric($_POST['shop_tel']) AND is_numeric($_POST['shop_cp']))
			{
				global $connect;
				$query = "call insert_magasin('".$_POST['shop_name']."','".$_POST['shop_city']."', '".$_POST['shop_code']."','".$_POST['shop_tel']."','".$_POST['shop_addr']."', '".$_POST['shop_cp']."');";
				mysql_query($query, $connect) or die(mysql_error());
				echo "<div class='box_success'>Nouveau magasin rajout&eacute; </div><br />";
			}
			else
				echo "<p class='box_error'>Le num&eacute;ro de t&eacute;l&eacute;phone ou le code postal ne doivent pas contenir de lettres</p> <br />";
			
		}
		else
			echo "<p class='box_error'>Certains champs n'ont pas &eacute;t&eacute; remplis </p> <br />";
		
}
?>
<center>
<div id="add_mag">
	<h1> Ajout d'un nouveau magasin </h1> <br />
	<form action="index.php?page=magasins&action=add" method="post">
		<table  border="0" cellspacing="8" cellpadding="40" width="400px">
		<tr > <td>Nom:</td><td><input type="text" name="shop_name" /></td> </tr>
		<tr > <td>Code Magasin :</td><td><input type="text" name="shop_code" /></td> </tr>
		<tr> <td>Adresse :</td><td><input type="text" name="shop_addr" /></td> </tr>
		<tr> <td>Ville :</td><td><input type="text" name="shop_city" /></td> </tr>
		<tr> <td>Code postal :</td><td><input type="text" name="shop_cp" /></td> </tr>
		<tr> <td>Telephone :</td> <td><input type="text" name="shop_tel" /></td> </tr>
		<tr><td></td><td><input type="submit" value="Ajouter"></td></tr>
	</table>
	<br />
</form>
</div>
</center>
<h1><center><a href="index.php?page=magasins"><img src="img/jamembo-back.png" width="30px" height="30px"/> Retour a la liste des magasins</a></center></h1>